<?php TPL::output('admin/global/header.tpl.htm'); ?>
<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->



<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3>站点管理</h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">站点列表</a></li>
				<li><a href="#tab2" class="">搜索</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">
			
				<?php if($_GET['action'] == 'search'){ ?>
					<div style="margin-bottom:5px;">共有 <?php echo intval($this->question_num); ?> 条符合条件的内容。</div>
				<?php } ?>
				
				<?php if($this->list){ ?>
				<form id="batchs_form" action="admin/question/question_batch/" method="post">
					<table class="list">
						<thead>
							<tr>
								<th style="width:20px;"><input type="checkbox" class="check-all"></th>
								<th style="width:280px;">站点标题</th>
								<?php if(get_setting('category_enable') == 'Y'){ ?>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-category_id__order-<?php if($_GET['sort_key'] == 'category_id' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">分类<?php if($_GET['sort_key'] == 'category_id'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<?php } ?>
								<th>所属标签</th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-answer_count__order-<?php if($_GET['sort_key'] == 'answer_count' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">回复数<?php if($_GET['sort_key'] == 'answer_count'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-view_count__order-<?php if($_GET['sort_key'] == 'view_count' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">浏览<?php if($_GET['sort_key'] == 'view_count'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-question_out_times__order-<?php if($_GET['sort_key'] == 'question_out_times' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">点击<?php if($_GET['sort_key'] == 'question_out_times'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-unverified_modify__order-<?php if($_GET['sort_key'] == 'unverified_modify' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">确认编辑<?php if($_GET['sort_key'] == 'unverified_modify'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-published_uid__order-<?php if($_GET['sort_key'] == 'published_uid' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">发布者<?php if($_GET['sort_key'] == 'published_uid'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-add_time__order-<?php if($_GET['sort_key'] == 'add_time' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">发布时间<?php if($_GET['sort_key'] == 'add_time'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-update_time__order-<?php if($_GET['sort_key'] == 'update_time' && $_GET['order'] == 'ASC'){ ?>DESC<?php }else{ ?>ASC<?php } ?>">最后更新时间<?php if($_GET['sort_key'] == 'update_time'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
								<th>操作</th>
							</tr>
						</thead>
						<tfoot>
							<tr>
								<td colspan="11">
									<div class="bulk-actions align-left"><a class="button" onClick="ajax_post($('#batchs_form'), _ajax_post_alert_processer); return false;" href="javascript:;">删除选择</a></div>
									<div class="pagination"><?php echo $this->pagination; ?></div>
									<div class="clear"></div>
								</td>
							</tr>
						</tfoot>
						<tbody style="border-bottom: 1px solid #ddd;">
							<?php foreach ($this->list AS $key => $val) { ?>
							<tr>
								<td><input type="checkbox" name="question_ids[]" value="<?php echo $val['question_id']; ?>"></td>
								<td><a href="question/<?php echo $val['question_id']; ?>" target="_blank" title="查看站点"><?php echo $val['question_content']; ?></a></td>
								<?php if(get_setting('category_enable') == 'Y'){ ?>
								<td><a href="admin/question/question_list/action-<?php echo $_GET['action']; ?>__category_id-<?php echo $val['category']['id']; ?>"><?php echo $val['category']['title']; ?></a></td>
								<?php } ?>
								<td><?php if($val['topics']){ ?><?php foreach($val['topics'] as $topic){ ?><a href="topic/<?php echo $topic['url_token']?>" target="_blank"><?php echo $topic['topic_title']; ?></a>&nbsp;<?php } ?><?php } ?></td>
								<td><?php if($val['answer_count']){ ?><a href="admin/question/answer_list/question_id-<?php echo $val['question_id']; ?>" title="查看回复"><?php echo $val['answer_count']; ?></a><?php }else{ ?>0<?php } ?></td>
								<td><?php echo $val['view_count']; ?></td>
								<td><?php echo $val['question_out_times']; ?></td>
								<td><?php if($val['unverified_modify']){ ?><a href="question/id-<?php echo $val['question_id']; ?>__column-log__rf-false" target="_blank">有</a><?php }else{ ?>无<?php } ?></td>
								<td><a href="people/<?php echo $val['user']['url_token']; ?>" target="_blank"><?php echo $val['user']['user_name']; ?></a></td>
								<td><?php echo date("Y-m-d H:i", $val['add_time']); ?></td>
								<td><?php echo date("Y-m-d H:i", $val['update_time']); ?></td>
								<td>
									<a href="publish/question_id-<?php echo $val['question_id']; ?>#question" title="修改" target="_blank"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/pencil.png" alt="修改" /></a> 
									<a href="admin/news/id-<?php echo $val['question_id']; ?>__name-<?php echo $val['question_content'] ?>">新闻</a> 
									<a href="javascript:" onclick="url2('<?php echo $val['question_id'];  ?>','<?php echo $val['question_url2'] ;?>')">中转地址</a> 
								</td>
									
							</tr>
							<?php } ?>
						</tbody>
					</table>
				</form>
				<?php } ?>
			</div>
			
			<div class="tab-content" id="tab2" style="display:none;">
				<form method="post" action="admin/question/question_list/" onsubmit="return false;" id="search_form">
				<input name="action" type="hidden" value="search"/>
				<p>
					<label> 关键词：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['keyword']); ?>" name="keyword" class="text-input small-input">
				</p>
				<div style="margin-top:5px;">
					<label> 分类：</label>
					<p style="width:100%; margin-bottom:5px; padding-bottom:3px;">
					<select name="category_id" style="float:left; width:200px;">
						<option value="0"></option>
						<?php echo $this->category_list; ?>
					</select>
					<label style=" float:left; padding-top:7px;margin-left:10px;"><input type="checkbox" value="1" name="category_child"<?php if(!$_GET['action'] || $_GET['category_child'] == '1'){ ?> checked="true"<?php } ?>> 包括子分类</label>
					</p>
				</div>
				<p>
					<label style="clear:both;"> 发起时间范围：</label>
					<input type="text" value="<?php echo base64_decode($_GET['start_date']); ?>" name="start_date" class="text-input date_picker" style="width:150px;"> -- <input type="text" value="<?php echo base64_decode($_GET['end_date']); ?>" name="end_date" class="text-input date_picker" style="width:150px;">
				</p>
				<p>
					<label> 发布者：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['username']); ?>" name="username" class="text-input small-input">
				</p>
				<p>
					<label> 回复数：</label>
					<input type="text" name="answer_count_min" value="<?php echo $_GET['answer_count_min']; ?>" class="text-input" style="width:40px;"> - <input type="text" name="answer_count_max" value="<?php echo $_GET['answer_count_max']; ?>" class="text-input" style="width:40px;">
				</p>
				<p>
					<label> 包含标签：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['topic']); ?>" name="topic" id="topic" class="text-input small-input">
				</p>
				<p>
					<label> 是否有最佳回复：<input type="checkbox" value="1" name="best_answer"<?php if($_GET['best_answer'] == '1'){ ?> checked="true"<?php } ?>> 有最佳回复</label>
				</p>
				<p style="clear:both;">
					<input type="button" onclick="ajax_post($('#search_form'), _form_process);" value="搜  索" class="button">
				</p>
				</form>
			</div>
			
		</div>
		<div class="clear"></div>
		<div id="notf_tip" style="display:none;" class="notification png_bg"> <a href="javascript:;" class="close"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/cross_grey_small.png" alt="关闭" /></a>
			<div id="notf_cont"></div>
		</div>
	</div>

<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->
<div id ="website_url_div" style="display:none;">
<input id ="website_url2_text" value ="aa" question_id="0">
</div>
</div>
<!-- main -->
<script>

$(function(){
	
	$('#website_url_div').dialog({
		modal: true,
		minHeight: false,
		resizable: false,
		autoOpen: false,
		minWidth: false,
		title:'添加/修改 中转地址',
		buttons : {
			'关闭' : function(){
				$(this).dialog("close");
			},
			'提交' : function(){
				 
				var arg = {
						'id':$('#website_url2_text').attr('question_id'),
						'url2':$('#website_url2_text').val()
				};
				var url = "<?php echo $this->ajaxUrl['url2']?>";
		
				 $.post(url,arg, function(data){
				        if(data.status){
				            location.reload();
				        }
				    },'json');
				 location.reload();
				$(this).dialog("close");
			},
			
		}
	});
	
});
function url2(id,url)
{
	$('#website_url2_text').attr('question_id',id);
	$('#website_url2_text').val(url)
	$('#website_url_div').dialog("open");
}

</script>
</body>
</html>
